package com.zifuchuan.zuoye;

import javax.print.DocFlavor;
import java.util.Scanner;

/*
请编写程序，由键盘录入一个字符串，统计字符串中英文字母和数字分别有多少个。
比如：Hello12345World中字母：10个，数字：5个。
 */
public class HomeWork04 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串:");
        String s = sc.nextLine();
        char[] chars = s.toCharArray();
        int bigcount = 0;
        int smallcount = 0;
        int numcount = 0;
        for (int i = 0; i < chars.length; i++) {
            // chars[i]
            if (chars[i] >= 'A' && chars[i] <= 'Z') {
                bigcount++;
            } else if (chars[i] >= 'a' && chars[i] <= 'z') {
                smallcount++;
            } else if (chars[i] >= '0' && chars[i] <= '9') {
                numcount++;
            }

        }
        int sum=0;
        sum += (bigcount+smallcount);
        System.out.println("字母的个数是:" + sum);
        System.out.println("数字字符的个数是:" + numcount);
    }

}
